#include "Texture.h"
#include "ResourcePool.h"


namespace Display
{
	Texture::Texture(ResourcePool * pool) : DeviceUserBase() , Resource(pool)
	{
		resView = nullptr;
	}


	Texture::~Texture(void)
	{
		if(resView != nullptr)
		{
			resView->Release();
			resView = nullptr;
		}
	}

	Texture * Texture::Create( ID3D11Device * device , ResourcePool * pool )
	{
		Texture * tex = new Texture(pool);
		tex->SetDevice(device);

		return tex;
	}



	void Texture::LoadFromFile( std::string fileName )
	{
		/*D3DX11CreateShaderResourceViewFromFileA(GetDevice(),fileName.c_str(),nullptr,
			nullptr,&resView,nullptr);*/
	}

	ID3D11ShaderResourceView * Texture::GetApiResource()
	{
		return resView;
	}

	void Texture::OnZeroRefReach()
	{
		pool->DeAllocateTexture(this);
	}

}